Switch motion hint emulation to be serial based.
authorAlexander Larsson <alexl@redhat.com>
Fri, 23 Jan 2009 20:07:53 +0000 (21:07 +0100)
committerAlexander Larsson <alex@localhost.localdomain>
Thu, 2 Apr 2009 08:15:26 +0000 (10:15 +0200)
For backends not supporting serials, just have
_gdk_windowing_window_get_next_serial return zero.

gdk/gdkdisplay.c
gdk/gdkdisplay.h
gdk/gdkevents.c
gdk/gdkinternals.h
gdk/gdkwindow.c
gdk/x11/gdkdisplay-x11.c
gdk/x11/gdkevents-x11.c

index 0092b5bc699bcd3e42c84f6caa1618a0ac84edd9..a8f027e73ef189e7f0529705875018d037959228 100644 (file)
@@ -444,6 +444,19 @@ _gdk_get_sm_client_id (void)
   return gdk_sm_client_id;
 }
 
+void
+_gdk_display_enable_motion_hints (GdkDisplay *display)
+{
+  gulong next_serial;
+  
+  if (display->pointer_info.motion_hint_serial != 0)
+    {
+      next_serial = _gdk_windowing_window_get_next_serial (display);
+      if (next_serial < display->pointer_info.motion_hint_serial)
+       display->pointer_info.motion_hint_serial = next_serial;
+    }
+}
+
 /**
  * gdk_display_get_pointer:
  * @display: a #GdkDisplay
index 4e1e7a325d1fa0e7359eb44e9d3da93b53b871c6..c3a7d62a66d07eaf528738410e0bd2345f044f65 100644 (file)
@@ -83,7 +83,7 @@ typedef struct
   gdouble toplevel_x, toplevel_y; 
   guint32 state;
   guint32 button;
-  gboolean motion_hint_paused; /* TRUE if we've sent a motion to a window with motion hints enabled */
+  gulong motion_hint_serial; /* 0 == didn't deliver hinted motion event */
 } GdkPointerWindowInfo;
 
 struct _GdkDisplay
index 08e47ace9f8d40331c2f63f5690fefe1dd54dcda..af94ecbffb6014f13da0807ad571b2c8b0e79bd8 100644 (file)
@@ -950,7 +950,7 @@ gdk_event_request_motions (const GdkEventMotion *event)
       gdk_device_get_state (event->device, event->window, NULL, NULL);
       
       display = gdk_drawable_get_display (event->window);
-      display->pointer_info.motion_hint_paused = FALSE;
+      _gdk_display_enable_motion_hints (display);
     }
 }
 
index e70f82c42c8797279806215956493d6cc9a8ed2c..4bb52535c33a40fe5c5a9681a89b0907208f408f 100644 (file)
@@ -333,6 +333,7 @@ void     _gdk_windowing_set_default_display     (GdkDisplay *display);
 gchar *_gdk_windowing_substitute_screen_number (const gchar *display_name,
                                                gint         screen_number);
 
+gulong   _gdk_windowing_window_get_next_serial  (GdkDisplay *display);
 void     _gdk_windowing_window_get_offsets      (GdkWindow  *window,
                                                 gint       *x_offset,
                                                 gint       *y_offset);
@@ -357,7 +358,8 @@ GdkWindow* _gdk_windowing_window_at_pointer  (GdkDisplay       *display,
                                              GdkModifierType  *mask);
 void _gdk_windowing_got_event                (GdkDisplay       *display,
                                              GList            *event_link,
-                                             GdkEvent         *event);
+                                             GdkEvent         *event,
+                                             gulong            serial);
 
 
 /* Return the number of bits-per-pixel for images of the specified depth. */
@@ -486,6 +488,8 @@ void _gdk_display_set_has_keyboard_grab (GdkDisplay *display,
                                         guint32 time);
 void _gdk_display_unset_has_keyboard_grab (GdkDisplay *display,
                                           gboolean implicit);
+void _gdk_display_enable_motion_hints     (GdkDisplay *display);
+
 
 void _gdk_window_invalidate_for_expose (GdkWindow       *window,
                                        const GdkRegion *region);
index 2ce4e0a7d1e9cd65040ea711013f75e84329d864..69fd9b83f08baac28426d94bfaf82b93d6dcc641 100644 (file)
@@ -5272,7 +5272,7 @@ gdk_window_get_pointer (GdkWindow   *window,
   if (mask)
     *mask = tmp_mask;
 
-  display->pointer_info.motion_hint_paused = FALSE;
+  _gdk_display_enable_motion_hints (display);
   
   return child;
 }
@@ -5847,7 +5847,7 @@ gdk_window_set_events (GdkWindow       *window,
   display = gdk_drawable_get_display (window);
   if ((private->event_mask & GDK_POINTER_MOTION_HINT_MASK) &&
       !(event_mask & GDK_POINTER_MOTION_HINT_MASK))
-    display->pointer_info.motion_hint_paused = FALSE;
+    _gdk_display_enable_motion_hints (display);
   
   private->event_mask = event_mask;
 }
@@ -8104,7 +8104,7 @@ _gdk_display_set_window_under_pointer (GdkDisplay *display,
   if (window)
     update_cursor (display);
 
-  display->pointer_info.motion_hint_paused = FALSE;
+  _gdk_display_enable_motion_hints (display);
 }
 
 void
@@ -8215,7 +8215,8 @@ get_event_window (GdkDisplay                 *display,
 
 static gboolean
 proxy_pointer_event (GdkDisplay                 *display,
-                    GdkEvent                   *source_event)
+                    GdkEvent                   *source_event,
+                    gulong                      serial)
 {
   GdkWindow *toplevel_window;
   GdkWindow *pointer_window;
@@ -8264,12 +8265,13 @@ proxy_pointer_event (GdkDisplay                 *display,
       if (event_win &&
          (evmask & GDK_POINTER_MOTION_HINT_MASK))
        {
-         if (display->pointer_info.motion_hint_paused)
+         if (display->pointer_info.motion_hint_serial != 0 &&
+             serial < display->pointer_info.motion_hint_serial)
            event_win = NULL; /* Ignore event */
          else
            {
              is_hint = TRUE;
-             display->pointer_info.motion_hint_paused = TRUE;
+             display->pointer_info.motion_hint_serial = G_MAXULONG;
            }
        }
       
@@ -8468,7 +8470,8 @@ gdk_window_print_tree (GdkWindow *window,
 void
 _gdk_windowing_got_event (GdkDisplay *display,
                          GList      *event_link,
-                         GdkEvent   *event)
+                         GdkEvent   *event,
+                         gulong      serial)
 {
   GdkWindow *event_window;
   GdkWindowObject *event_private;
@@ -8569,15 +8572,13 @@ _gdk_windowing_got_event (GdkDisplay *display,
 
   if (display->pointer_info.state != old_state ||
       display->pointer_info.button != old_button)
-    {
-      /* Enable motions for the window */
-      display->pointer_info.motion_hint_paused = FALSE;
-    }
+    _gdk_display_enable_motion_hints (display);
  
   unlink_event = FALSE;
   if (is_motion_type (event->type))
     unlink_event = proxy_pointer_event (display,
-                                        event);
+                                        event,
+                                       serial);
   else if (is_button_type (event->type))
     unlink_event = proxy_button_event (event);
 
index 4559fabce1ba8c33446d9bdd151f0e00328cb9ea..a7f57aa61d7d003f9085484a83e3ac872fa17d4c 100644 (file)
@@ -444,6 +444,13 @@ process_internal_connection (GIOChannel  *gioc,
   return TRUE;
 }
 
+gulong
+_gdk_windowing_window_get_next_serial (GdkDisplay *display)
+{
+  return NextRequest (GDK_DISPLAY_XDISPLAY (display));
+}
+
+
 static GdkInternalConnection *
 gdk_add_connection_handler (Display *display,
                            guint    fd)
index 41de19c16f05f6acbc771c7ba3474d3108d403af..3b61e830bd3d43a42d313892e50b9cdcf335bdfc 100644 (file)
@@ -2352,7 +2352,7 @@ _gdk_events_queue (GdkDisplay *display)
       if (gdk_event_translate (display, event, &xevent, FALSE))
        {
          ((GdkEventPrivate *)event)->flags &= ~GDK_EVENT_PENDING;
-          _gdk_windowing_got_event (display, node, event);
+          _gdk_windowing_got_event (display, node, event, xevent.xany.serial);
        }
       else
        {